#pragma once
#include <map>
#include <list>
#include "CLComRecord.h"
#include "CLocalObject.h"
#include "CLComString.h"
#include "CRecordInfo.h"

class CRecord :
    public CLComRecord,
	public CLocalObject
{
public:
	CRecord(void* ppRogram);
	~CRecord();
public:
	virtual void Clear();
public:
	virtual void StartNewSerial();
public:
	virtual void SetChangeCallback(PCHANGECALLBACK pcallback);
public:
	virtual void GetRecords(list<SRecordInfo>& vecBackList,
		SRecordInfo& currentRecord,
		list<SRecordInfo>& nextList);

public:
	virtual void UnableRecord();
	virtual void EnableRecord();
public:
	virtual void RecordData(ERECORD_DATA_OPERATE_TYPE otype, ERECORD_DATATYPE dType, 
        CLComString opdesc, CLComString id);

public:
	virtual bool GoBack(int recordID);
	virtual bool GoNext(int recordID);
public:
	virtual bool HaveNext();
	virtual bool HaveBack();
	virtual bool HaveChange();
private:
	void Trans2SAOILogicRecord(CRecordInfo& sourceRecord, SRecordInfo& dstRecord);
	SRecordInfo Trans2SAOILogicRecord(CRecordInfo& sourceRecord);
private:
	void GetBackRecords(list<SRecordInfo>& vecBackList);
	void GetCurrentRecords(SRecordInfo& currentRecord);
	void GetNextRecords(list<SRecordInfo>& nextList);
private:
	void*			m_pPrgram;
	PCHANGECALLBACK m_pcallback;
	int				m_nOPSUMIndex;
	int				m_nOPCurrentIndex;

	map<int, CRecordInfo>		m_mapOperateBakRecords;
	CRecordInfo					m_currentRecord;
	map<int, CRecordInfo>		m_mapOperateNexRecords;

	bool			m_bCanRecord;
};

